package com.xw.lianshou.xuexi.pachong;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

public class TestPa {
    public static void main(String[] args) {

        try {
            chaCainiaoBiJi("https://www.runoob.com/w3cnote_genre/code/page/1");
        } catch (IOException e) {
            e.printStackTrace();
        }


//            System.out.println(document);
    }

    private static void chaCainiaoBiJi(String url) throws IOException {
        Document document = Jsoup.connect(url).get();
        Elements elements = document.select("div.post-intro");
        Elements elements1 = document.select("li.next-page");
        biprint(elements);
        if (elements1 != null){
            chaCainiaoBiJi(elements1.select("a").attr("href"));
        }
    }

    private static void biprint(Elements elements) {
        for (int i = 0; i < elements.size(); i++){
            System.out.println(elements.select("a").get(i).text());
            System.out.println(elements.select("a").get(i).attr("href"));
        }
    }
}
